<template>
  <div class="teacher-dashboard">
    <!-- 主要内容区域 -->
    <div class="dashboard-container">
      <!-- 左侧主内容区 -->
      <div class="main-content">
        <!-- 标题区域 -->
        <div class="title-section">
          <div class="welcome-info">
            <div class="weather-icon">☀️</div>
            <div class="welcome-text">
              <span class="greeting">{{ $t('assets.dashboard.welcomeBack') }}，{{ userName }}</span>
            </div>
          </div>
        </div>

        <!-- 功能卡片区 -->
        <div class="function-cards">
          <div class="card-item purple-card">
            <div class="card-content">
              <div class="card-header">
                <div class="card-icon">
                  <img src="@/assets/task.png" alt="数学任务" />
                </div>
                <h3>{{ $t('assets.dashboard.mathTask') }}</h3>
              </div>
              <p>{{ $t('assets.dashboard.mathTaskDesc') }}</p>
            </div>
            <div class="card-actions">
              <button class="action-btn primary-btn" @click="createTask">
                <span class="btn-text">{{ $t('assets.dashboard.createTask') }}</span>
                <div class="btn-arrow">
                  <img src="@/assets/home02.png" alt="箭头" />
                </div>
              </button>
              <button class="action-btn secondary-btn" @click="goToMathTasks">
                <div class="secondary-icon">
                  <img src="@/assets/home01.png" alt="任务管理" />
                </div>
                <span>{{ $t('assets.dashboard.taskManagement') }}</span>
              </button>
            </div>
          </div>

          <div class="card-item green-card">
            <div class="card-content">
              <div class="card-header">
                <div class="card-icon">
                  <img src="@/assets/TeachingTasks.png" alt="智能批改" />
                </div>
                <h3>{{ $t('assets.dashboard.intelligentGrading') }}</h3>
              </div>
              <p>{{ $t('assets.dashboard.intelligentGradingDesc') }}</p>
            </div>
            <div class="card-actions">
              <button class="action-btn primary-btn" @click="startGrading">
                <span class="btn-text">{{ $t('assets.dashboard.intelligentGrading') }}</span>
                <div class="btn-arrow">
                  <img src="@/assets/home02.png" alt="箭头" />
                </div>
              </button>
              <button class="action-btn secondary-btn" @click="goToGradingHistory">
                <div class="secondary-icon">
                  <img src="@/assets/home01.png" alt="批改记录" />
                </div>
                <span>{{ $t('assets.dashboard.gradingHistory') }}</span>
              </button>
            </div>
          </div>

          <div class="card-item blue-card">
            <div class="card-content">
              <div class="card-header">
                <div class="card-icon">
                  <img src="@/assets/home01.png" alt="学生档案" />
                </div>
                <h3>{{ $t('assets.dashboard.studentProfile') }}</h3>
              </div>
              <p>{{ $t('assets.dashboard.studentProfileDesc') }}</p>
            </div>
            <div class="card-actions">
              <button class="action-btn primary-btn" @click="goToStudentList">
                <span class="btn-text">{{ $t('assets.dashboard.studentProfile') }}</span>
                <div class="btn-arrow">
                  <img src="@/assets/home02.png" alt="箭头" />
                </div>
              </button>
              <button class="action-btn secondary-btn" @click="goToStudentList">
                <div class="secondary-icon">
                  <img src="@/assets/home01.png" alt="添加学生" />
                </div>
                <span>{{ $t('assets.dashboard.addStudent') }}</span>
              </button>
            </div>
          </div>
        </div>

        <!-- 分类列表区 -->
        <div class="category-section">
          <!-- 分类标签 -->
          <div class="category-tabs">
            <button v-for="category in categories" :key="category.key"
              :class="['category-tab-btn', { active: activeCategory === category.key }]"
              @click="activeCategory = category.key">
              {{ category.label }}
              <span class="count">{{ category.count }}</span>
            </button>
          </div>

          <!-- 分割线 -->
          <div class="divider-line"></div>

          <!-- 状态标签 -->
          <div class="status-tabs">
            <button v-for="status in statusList" :key="status.key"
              :class="['status-tab-btn', { active: activeStatus === status.key }]" @click="activeStatus = status.key">
              {{ status.label }}
            </button>
          </div>

          <!-- 作业列表 -->
          <div class="homework-list">
            <div v-for="homework in filteredHomework" :key="homework.id" class="homework-item"
              @click="viewHomework(homework)">
              <!-- <div class="subject-icon-wrapper" :class="homework.subject"> -->
                <img :src="getSubjectIconPath(homework.subject)" :alt="homework.subject" class="subject-icon" />
              <!-- </div> -->
              <div class="homework-content">
                <h4 class="homework-title">{{ homework.title }}</h4>
                <p class="homework-desc">{{ homework.description }}</p>
              </div>
              <div class="homework-meta">
                <div class="homework-time">
                  <div class="time-label">创建时间</div>
                  <div class="time-value">{{ formatDate(homework.createdAt) }}</div>
                </div>
                <div class="homework-time">
                  <div class="time-label">完成时间</div>
                  <div class="time-value">{{ formatDate(homework.dueDate) }}</div>
                </div>
              </div>
              <div class="homework-arrow">
                <img src="@/assets/right.png" alt="查看详情" class="arrow-icon" />
              </div>
            </div>

            <!-- 空状态 -->
            <EmptyState
              v-if="filteredHomework.length === 0"
              :text="$t('assets.dashboard.noTasksYet')"
              :button-text="$t('assets.dashboard.createTeachingTask')"
              @action="createTask"
            />
          </div>
        </div>
      </div>

      <!-- 右侧快捷入口区 -->
      <div class="sidebar-content">
        <!-- 快捷入口区 -->
        <div class="quick-actions-section">
          <div class="section-header">
            <h3>{{ $t('assets.dashboard.quickAccess') }}</h3>
          </div>
          <div class="quick-actions">
            <div class="quick-action-item" @click="goToAIGrading">
              <div class="action-icon">
                <img src="@/assets/Correction.png" alt="批改记录" />
              </div>
              <span>{{ $t('assets.dashboard.gradingHistory') }}</span>
            </div>
            <div class="quick-action-item" @click="refreshData">
              <div class="action-icon">
                <img src="@/assets/errorCollection.png" alt="智能错题库" />
              </div>
              <span>{{ $t('assets.dashboard.errorCollection') }}</span>
            </div>
            <div class="quick-action-item" @click="createTask">
              <div class="action-icon">
                <img src="@/assets/TeachingTasks.png" alt="创建任务" />
              </div>
              <span>{{ $t('assets.dashboard.createTask') }}</span>
            </div>
            <div class="quick-action-item" @click="goToStudentArchives">
              <div class="action-icon">
                <img src="@/assets/document.png" alt="学生档案" />
              </div>
              <span>{{ $t('assets.dashboard.studentProfile') }}</span>
            </div>
          </div>
        </div>

        <!-- 公告信息轮播区域 -->
        <el-carousel height="200px" :interval="4000" :loop="true" indicator-position="outside" class="custom-carousel">
          <el-carousel-item v-for="(item, index) in carouselItems" :key="index">
            <div class="carousel-item-content" :style="{ backgroundImage: item.image ? `url(${item.image})` : 'none' }">
              <div class="carousel-overlay"></div>
              <div class="carousel-text">
                <h4>{{ item.title }}</h4>
                <p>{{ item.description }}</p>
              </div>
            </div>
          </el-carousel-item>
        </el-carousel>

        <!-- 公告区域 -->
        <div class="announcement-section">
          <div class="section-header">
            <h3>{{ $t('assets.dashboard.announcement') }}</h3>
          </div>
          <div class="announcement-list">
            <div v-for="announcement in announcements" :key="announcement.id" class="announcement-item"
              @click="viewAnnouncement(announcement)">
              <div class="announcement-tag" :class="announcement.type">
                {{ announcement.tag }}
              </div>
              <div class="announcement-content">
                <div class="announcement-title">{{ announcement.title }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 摄像头弹窗 -->
    <el-dialog v-model="showCameraModal" title="智能批改" width="80%" :before-close="() => showCameraModal = false">
      <CameraCapture @close="showCameraModal = false" />
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useAuthStore } from '@/stores/auth'
import { t as $t } from '@/plugins/simpleI18n'
import CameraCapture from '@/components/shared/Camera/CameraCapture.vue'
import EmptyState from '@/components/shared/Common/EmptyState.vue'

const router = useRouter()
const authStore = useAuthStore()

// 响应式数据
const activeCategory = ref('all')
const activeStatus = ref('all')
const showCameraModal = ref(false)

// 计算属性
const userName = computed(() => {
  return authStore.currentUser?.name || $t('common.teacher')
})

// 分类数据
const categories = ref([
  { key: 'all', label: $t('assets.taskList.all'), count: 12 },
  { key: 'math', label: $t('assets.subjects.math'), count: 12 },
  { key: 'chinese', label: $t('assets.subjects.chinese'), count: 14 },
  { key: 'english', label: $t('assets.subjects.english'), count: 12 },
  { key: 'other', label: $t('assets.subjects.other'), count: 12 }
])

// 状态数据
const statusList = ref([
  { key: 'all', label: $t('assets.taskList.all'), count: 12 },
  { key: 'pending', label: $t('assets.taskList.pending'), count: 3 },
  { key: 'grading', label: $t('assets.taskList.grading'), count: 2 },
  { key: 'correction', label: $t('assets.taskList.correction'), count: 1 },
  { key: 'correcting', label: $t('assets.taskList.correcting'), count: 1 },
  { key: 'completed', label: $t('assets.taskList.completed'), count: 5 }
])

// 作业列表数据
const homeworkList = ref([
  {
    id: 1,
    title: $t('assets.sampleData.mathTask'),
    description: $t('assets.sampleData.mathTaskDesc'),
    subject: 'math',
    status: 'pending',
    createdAt: new Date('2056-02-05 12:57'),
    dueDate: new Date('2056-02-05 12:57')
  },
  {
    id: 2,
    title: $t('assets.sampleData.chineseTask'),
    description: $t('assets.sampleData.chineseTaskDesc'),
    subject: 'chinese',
    status: 'grading',
    createdAt: new Date('2056-02-05 12:57'),
    dueDate: new Date('2056-02-05 12:57')
  },
  {
    id: 3,
    title: $t('assets.sampleData.englishTask'),
    description: $t('assets.sampleData.englishTaskDesc'),
    subject: 'english',
    status: 'completed',
    createdAt: new Date('2056-02-05 12:57'),
    dueDate: new Date('2056-02-05 12:57')
  },
  {
    id: 4,
    title: $t('assets.sampleData.otherTask'),
    description: $t('assets.sampleData.otherTaskDesc'),
    subject: 'other',
    status: 'correction',
    createdAt: new Date('2056-02-05 12:57'),
    dueDate: new Date('2056-02-05 12:57')
  },
  {
    id: 5,
    title: $t('assets.sampleData.mathTask'),
    description: $t('assets.sampleData.mathTaskDesc'),
    subject: 'other',
    status: 'correcting',
    createdAt: new Date('2056-02-05 12:57'),
    dueDate: new Date('2056-02-05 12:57')
  },
  {
    id: 6,
    title: $t('assets.sampleData.chineseTask'),
    description: $t('assets.sampleData.chineseTaskDesc'),
    subject: 'chinese',
    status: 'pending',
    createdAt: new Date('2056-02-05 12:57'),
    dueDate: new Date('2056-02-05 12:57')
  }
])

// 轮播图数据
const carouselItems = ref([
  {
    title: $t('assets.carousel.intelligentUpgrade'),
    description: $t('assets.carousel.intelligentUpgradeDesc'),
    image: '/src/assets/swpier/swpier01.jpg'
  },
  {
    title: $t('assets.carousel.taskManagement'),
    description: $t('assets.carousel.taskManagementDesc'),
    image: '/src/assets/swpier/swiper02.jpg'
  },
  {
    title: $t('assets.carousel.studentProfile'),
    description: $t('assets.carousel.studentProfileDesc'),
    image: '/src/assets/swpier/swiper03.jpg'
  },
  {
    title: $t('assets.carousel.errorCollection'),
    description: $t('assets.carousel.errorCollectionDesc'),
    image: '/src/assets/swpier/swiper04.jpg'
  },
  {
    title: $t('assets.carousel.dataAnalysis'),
    description: $t('assets.carousel.dataAnalysisDesc'),
    image: '/src/assets/swpier/swiper05.jpg'
  }
])

// 公告数据
const announcements = ref([
  { id: 1, title: $t('assets.announcements.latestActivity'), type: 'activity', tag: $t('assets.announcements.activity') },
  { id: 2, title: $t('assets.announcements.contentPending'), type: 'info', tag: $t('assets.announcements.message') },
  { id: 3, title: $t('assets.announcements.trialExpiring'), type: 'notice', tag: $t('assets.announcements.notice') },
  { id: 4, title: $t('assets.announcements.systemUpgrade'), type: 'notice', tag: $t('assets.announcements.notice') },
  { id: 5, title: $t('assets.announcements.contentApproved'), type: 'info', tag: $t('assets.announcements.message') },
  { id: 6, title: $t('assets.announcements.systemUpgrade'), type: 'notice', tag: $t('assets.announcements.notice') },
  { id: 7, title: $t('assets.announcements.systemUpgrade'), type: 'notice', tag: $t('assets.announcements.notice') },
  { id: 8, title: $t('assets.announcements.systemUpgrade'), type: 'notice', tag: $t('assets.announcements.notice') },
  { id: 9, title: $t('assets.announcements.systemUpgrade'), type: 'notice', tag: $t('assets.announcements.notice') },
  { id: 10, title: $t('assets.announcements.systemUpgrade'), type: 'notice', tag: $t('assets.announcements.notice') }
])

// 计算过滤后的作业列表
const filteredHomework = computed(() => {
  let filtered = homeworkList.value

  if (activeCategory.value !== 'all') {
    filtered = filtered.filter(item => item.subject === activeCategory.value)
  }

  if (activeStatus.value !== 'all') {
    filtered = filtered.filter(item => item.status === activeStatus.value)
  }

  return filtered
})

// 方法
const formatDate = (date: Date) => {
  return date.toLocaleString('zh-CN', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit'
  })
}

const getSubjectIconPath = (subject: string) => {
  const iconPaths: Record<string, string> = {
    math: '/src/assets/subject/mathico.png',
    chinese: '/src/assets/subject/chineseico.png',
    english: '/src/assets/subject/englishico.png',
    other: '/src/assets/subject/others.png'
  }
  return iconPaths[subject] || iconPaths.other
}



// 导航方法
// 快捷入口跳转方法
const goToAIGrading = () => {
  // 【批改记录】进入 批改作业-历史批改记录页
  router.push('/teacher/homework-review/history')
}

const refreshData = () => {
  // 【智能错题库】进入 批改作业-错题集
  router.push('/teacher/homework-review/error-collection')
}

const createTask = () => {
  // 【创建任务】点击创建任务进入任务创建向导
  router.push({ name: 'task-creation-wizard' })
}

const goToStudentArchives = () => {
  // 【学生档案】点击后进入学生档案列表
  router.push('/teacher/StudentManagement')
}

// 功能卡片跳转方法
const startGrading = () => {
  // 【智能批改】点击后可调用摄像头批改作业
  // 这里需要打开摄像头组件，可以通过弹窗或路由跳转
  showCameraModal.value = true
}

const goToGradingHistory = () => {
  // 【批改记录】进入批改作业-历史批改记录页
  router.push('/teacher/homework-review/grading-history')
}

const goToStudentList = () => {
  // 【学生档案】点击后进入学生档案列表
  router.push('/teacher/student-management')
}

const goToMathTasks = () => {
  router.push('/teacher/teaching-tasks')
}



// 定义作业类型
interface Homework {
  id: number
  title: string
  description: string
  subject: string
  status: string
  createdAt: Date
  dueDate: Date
}

// 定义公告类型
interface Announcement {
  id: number
  title: string
  type: string
  tag: string
}

const viewHomework = (homework: Homework) => {
  console.log('查看作业:', homework)
}

const viewAnnouncement = (announcement: Announcement) => {
  console.log('查看公告:', announcement)
}

onMounted(() => {
  console.log('教师工作台加载完成')
})
</script>

<style scoped>
.teacher-dashboard {
  height: 100%;
  padding: 0;
  overflow: hidden;
  background: var(--content-bg-color);
  color: var(--text-color-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
  box-sizing: border-box;
}

.dashboard-container {
  display: flex;
  height: 100%;
  gap: 0;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* 左侧主内容区 */
.main-content {
  flex: 1;
  height: 100%;
  overflow: visible;
  padding: 20px;
  margin: 0;
  min-width: 0; /* 允许flex项目收缩 */
  box-sizing: border-box;
}

/* 标题区域 */
.title-section {
  margin-bottom: 24px;
}

.welcome-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.weather-icon {
  font-size: 24px;
}

.greeting {
  font-size: 18px;
  font-weight: 600;
  color: #303133;
}

/* 功能卡片区 */
.function-cards {
  display: flex;
  gap: 20px;
  margin-bottom: 32px;
  flex-wrap: wrap; /* 允许换行 */
  box-sizing: border-box;
}

.card-item {
  flex: 1;
  border-radius: 8px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s ease, background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--card-bg-color);
  border: 1px solid var(--border-color-secondary);
  box-shadow: var(--card-shadow);
  color: var(--text-color-primary);
  min-height: 200px;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.card-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* 卡片渐变背景 - 按照UI设计图 */
.card-item.purple-card {
  background: #f8f4ff;
  border: 1px solid #e8d8ff;
  color: #333;
}

.card-item.green-card {
  background: #f0fff4;
  border: 1px solid #d4edda;
  color: #333;
}

.card-item.blue-card {
  background: #f0f8ff;
  border: 1px solid #cce7ff;
  color: #333;
}

.card-content {
  flex: 1;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.card-icon {
  text-align: center;
  line-height: 13px;
  width: 21px;
  aspect-ratio: 1;
  flex-shrink: 0;
}

.card-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-content h3 {
  font-size: 16px;
  font-weight: 600;
  color: #000000;
  margin: 0;
}

.card-actions span {
  color: #ffffff;
}

.secondary-btn span {
  color: #ffffff;
}

.card-actions .btn-text {
  color: #ffffff;
}

.card-content p {
  font-size: 14px;
  color: rgb(0, 0, 0);
  line-height: 1.5;
  margin: 0;
}

/* 卡片按钮区域 */
.card-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.card-actions span {
  color: #000000;
}

.card-actions .btn-text {
  color: #ffffff;
}

.action-btn {
  border: none;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
}

.primary-btn {
  background: #2c2c2c;
  color: #fff;
  padding: 6px 12px;
  border-radius: 25px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 120px;
}

.primary-btn:hover {
  background: #404040;
  transform: translateY(-1px);
}

.btn-text {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
}

.btn-arrow {
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-arrow img {
  width: 16px;
  aspect-ratio: 1;
  object-fit: contain;
  filter: none;
}

.secondary-btn {
  padding: 6px 10px;
  background: #e9ebf3;
  color: #fff;
  /* border: 1px solid rgba(255, 255, 255, 0.3); */
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.secondary-icon {
  width: 16px;
  height: 16px;
}

.secondary-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: brightness(0) invert(0.3);
}

/* 分类列表区 */
.category-section {
  background: #e8f3fe;
  border-radius: 15px;
  padding: 20px;
  border: 1px solid #e4e7ed;
}

/* 分类标签样式 */
.category-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.category-tab-btn {
  background: transparent;
  border: none;
  padding: 8px 16px;
  font-size: 16px;
  color: #909399;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  border-radius: 4px;
}

.category-tab-btn:hover {
  color: #606266;
}

.category-tab-btn.active {
  color: #303133;
  font-weight: 600;
}

.category-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 2px;
  background-color: #3e3e3e;
  border-radius: 1px;
}

.category-tab-btn .count {
  margin-left: 4px;
  font-size: 12px;
  background-color: #d9ecff;
    padding: 5px;
    border-radius: 15px;
}

/* 分割线样式 */
.divider-line {
  height: 1px;
  background-color: #e4e7ed;
  margin: 16px 0;
}

/* 状态标签样式 */
.status-tabs {
  display: flex;
  gap: 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.status-tab-btn {
  background: transparent;
  border: none;
  padding: 8px 0;
  font-size: 14px;
  color: #333333;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  border-radius: 0;
  position: relative;
}

.status-tab-btn:hover {
  color: #409EFF;
}

.status-tab-btn.active {
  color: #409EFF;
  background-color: #ffffff;
  border-radius: 16px;
  padding: 8px 16px;
}
  
/* 作业列表 */
.homework-list {
  max-height: 375px;
  overflow-y: auto;
}



.homework-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  border: 1px solid #e8e8e8;
  background-color: #ffffff;
  border-radius: 12px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.3s;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  height: 65px; /* PC端固定高度65px */
  min-height: 65px;
}

.homework-item:hover {
  border-color: #409EFF;
  background-color: #f0f9ff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.subject-icon-wrapper {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  flex-shrink: 0;
}

.subject-icon-wrapper.math {
  background: #e8f4fd;
}

.subject-icon-wrapper.chinese {
  background: #e8f4fd;
}

.subject-icon-wrapper.english {
  background: #fff3e0;
}

.subject-icon-wrapper.other {
  background: #fff3e0;
}

.subject-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.homework-content {
  flex: 1;
  min-width: 0;
}

.homework-title {
  font-size: 16px;
  font-weight: 600;
  color: #303133;
  margin: 0 0 6px 0;
  line-height: 1.4;
}

.homework-desc {
  font-size: 14px;
  color: #909399;
  margin: 0;
  line-height: 1.4;
}

.homework-meta {
  display: flex;
  flex-direction: row;
  gap: 60px;
  min-width: 280px;
  justify-content: flex-start;
  flex-shrink: 0;
}

.homework-time {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  min-width: 110px;
}

.time-label {
  color: #909399;
  font-size: 12px;
  line-height: 1.2;
}

.time-value {
  color: #606266;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 500;
}

.homework-arrow {
  flex-shrink: 0;
  margin-left: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.arrow-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  opacity: 0.6;
  transition: opacity 0.3s;
}

.homework-item:hover .arrow-icon {
  opacity: 1;
}

/* 右侧快捷入口区 */
.sidebar-content {
  width: 300px;
  min-width: 280px; /* 设置最小宽度 */
  max-width: 320px; /* 设置最大宽度 */
  height: 100%;
  overflow-y: auto;
  padding-left: 10px;
  display: flex;
  flex-shrink: 0; /* 防止收缩 */
  box-sizing: border-box;
  flex-direction: column;
  gap: 0;
}

/* 快捷入口区 */
.quick-actions-section {
  background: var(--card-bg-color);
  color: var(--text-color-primary);
  border-radius: 8px;
  padding: 20px;
  border: 1px solid var(--border-color-secondary);
  box-shadow: var(--card-shadow);
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 16px;
}

.quick-action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
  gap: 8px;
}

.quick-action-item:hover {
  background-color: #f5f7fa;
  transform: translateY(-1px);
}

.action-icon {
  width: 32px;
  height: 32px;
  background: #f7f8fa;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

.action-icon img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.quick-action-item span {
  font-size: 11px;
  color: #606266;
  font-weight: 500;
  line-height: 1.2;
}

/* 轮播图区域 */
.carousel-item-content {
  position: relative;
  width: 100%;
  height: 200px;
  overflow: hidden;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-end;
}

.carousel-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0) 100%);
  z-index: 1;
}

.carousel-text {
  position: relative;
  z-index: 2;
  color: white;
  padding: 20px;
  width: 100%;
}

.carousel-text h4 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 8px 0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.carousel-text p {
  font-size: 14px;
  margin: 0;
  opacity: 0.9;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* 自定义轮播图导航条样式 */
.custom-carousel :deep(.el-carousel__indicators) {
  bottom: 6px;
}

.custom-carousel :deep(.el-carousel__indicator) {
  padding: 0px 4px;
}

.custom-carousel :deep(.el-carousel__button) {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.647);
  border: none;
  transition: all 0.3s ease;
}

.custom-carousel :deep(.el-carousel__indicator.is-active .el-carousel__button) {
  width: 16px;
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.9);
}

.section-header {
  margin-bottom: 16px;
}

.section-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #303133;
  margin: 0;
}

/* 公告区域 */
.announcement-section {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  border: 1px solid #e4e7ed;
}

.announcement-list {
  max-height: 300px;
  overflow-y: auto;
}

.announcement-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  cursor: pointer;
}

.announcement-item:last-child {
  padding-bottom: 0;
}

.announcement-tag {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  flex-shrink: 0;
  min-width: 32px;
  text-align: center;
}

.announcement-tag.activity {
  background: #fef0e6;
  color: #e6a23c;
}

.announcement-tag.info {
  background: #e1f3ff;
  color: #17c0eb;
}

.announcement-tag.warning {
  background: #fef0e6;
  color: #e6a23c;
}

.announcement-tag.notice {
  background: #e1f3ff;
  color: #409EFF;
}

.announcement-content {
  flex: 1;
  overflow: hidden;
}

.announcement-title {
  font-size: 14px;
  color: #606266;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

/* 滚动条样式 */
.sidebar-content::-webkit-scrollbar,
.homework-list::-webkit-scrollbar,
.announcement-list::-webkit-scrollbar {
  width: 6px;
}

.sidebar-content::-webkit-scrollbar-track,
.homework-list::-webkit-scrollbar-track,
.announcement-list::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb,
.homework-list::-webkit-scrollbar-thumb,
.announcement-list::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover,
.homework-list::-webkit-scrollbar-thumb:hover,
.announcement-list::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 响应式设计 */
@media (max-width: 1400px) {
  .dashboard-container {
    gap: 0;
  }

  .sidebar-content {
    width: 280px;
    min-width: 260px;
  }
}

@media (max-width: 1200px) {
  .dashboard-container {
    flex-direction: column;
    height: auto;
    gap: 0;
  }

  .sidebar-content {
    width: 100%;
    min-width: auto;
    max-width: none;
    padding-left: 0;
    padding-top: 20px;
    flex-shrink: 1;
  }

  .main-content {
    height: auto;
    padding: 0;
    margin: 0;
  }

  .function-cards {
    flex-direction: column;
  }

  .card-item {
    flex: none;
    min-width: auto;
  }
}

/* iPad端样式优化 */
@media (min-width: 768px) and (max-width: 1024px) {
  .teacher-dashboard {
    font-size: 16px;
  }

  .dashboard-container {
    gap: 18px;
    padding: 0 16px;
  }

  .function-cards {
    gap: 16px;
  }

  .card-item {
    min-width: 240px;
    padding: 18px;
  }

  .card-content h3 {
    font-size: 17px;
  }

  .card-content p {
    font-size: 15px;
  }

  .action-btn {
    min-height: 44px; /* iPad 触摸优化 */
    font-size: 15px;
  }

  .primary-btn {
    padding: 10px 16px;
    min-width: 140px;
  }

  .secondary-btn {
    padding: 10px 16px;
  }

  .homework-item {
    height: auto;
    min-height: 70px; /* 增加触摸区域 */
    padding: 18px 20px;
  }

  .homework-title {
    font-size: 16px;
  }

  .homework-desc {
    font-size: 14px;
  }

  .time-label,
  .time-value {
    font-size: 12px;
  }

  .homework-meta {
    gap: 50px;
    min-width: 260px;
  }

  .subject-icon {
    width: 32px;
    height: 32px;
  }

  .quick-action-item {
    padding: 16px 12px;
    min-height: 44px; /* 触摸优化 */
  }

  .action-icon {
    width: 36px;
    height: 36px;
  }

  .action-icon img {
    width: 22px;
    height: 22px;
  }

  .quick-action-item span {
    font-size: 12px;
  }

  .category-tab-btn,
  .status-tab-btn {
    min-height: 44px; /* 触摸优化 */
    padding: 12px 20px;
    font-size: 15px;
  }

  .announcement-item {
    padding: 18px 0;
    min-height: 44px;
  }

  .announcement-title {
    font-size: 15px;
  }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
  .teacher-dashboard {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  }

  .card-item,
  .homework-item,
  .quick-action-item,
  .announcement-item,
  .category-tab-btn,
  .status-tab-btn {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  }

  .action-btn {
    min-height: 44px;
    min-width: 44px;
  }

  .homework-item {
    min-height: 60px;
  }

  .quick-action-item {
    min-height: 60px;
    padding: 16px 8px;
  }
}

@media (max-width: 768px) {
  .function-cards {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 12px;
  }

  .quick-actions-section {
    padding: 16px;
  }

  .action-icon {
    width: 28px;
    height: 28px;
  }

  .action-icon img {
    width: 16px;
    height: 16px;
  }

  .quick-action-item span {
    font-size: 10px;
  }

  .category-tabs,
  .status-tabs {
    justify-content: center;
  }

  .homework-item {
    height: auto;
    min-height: 50px;
    padding: 12px 16px;
  }

  .homework-title {
    font-size: 14px;
  }

  .homework-desc {
    font-size: 12px;
  }

  .subject-icon-wrapper {
    width: 36px;
    height: 36px;
  }

  .subject-icon {
    width: 24px;
    height: 24px;
  }

  .homework-meta {
    display: none;
  }
}

@media (max-width: 480px) {
  .dashboard-container {
    gap: 16px;
  }

  .card-item {
    flex-direction: column;
    text-align: center;
  }

  .quick-actions {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 8px;
  }

  .quick-actions-section {
    padding: 12px;
  }

  .quick-action-item {
    flex-direction: column;
    padding: 8px;
    gap: 6px;
  }

  .action-icon {
    width: 24px;
    height: 24px;
  }

  .action-icon img {
    width: 14px;
    height: 14px;
  }

  .quick-action-item span {
    font-size: 9px;
  }
}
</style>